﻿Imports System.Data.SqlClient


Public Class CustomerEditor

    Dim cmd As New SqlCommand
    Private Sub CustomerEditor_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        condb()
    End Sub

    Private Sub btnaddeditor_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnaddeditor.Click
        cmd.Connection = cn
        cmd.CommandText = "insert into tblcustomer values(N'" & txtname.Text & "',N'" & txtgender.Text & "',N'" & txtaddress.Text & "',N'" & txtphon.Text & "',N'" & txtdescription.Text & "')"
        cmd.ExecuteNonQuery()
        Me.DialogResult = Windows.Forms.DialogResult.OK
    End Sub

    Private Sub btnupdate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnupdate.Click
        cmd.Connection = cn
        cmd.CommandText = "update tblcustomer set Name=N'" & txtname.Text & "',sex=N'" & txtgender.Text & "',Address=N'" & txtaddress.Text & "',phone=N'" & txtphon.Text & "',description=N'" & txtdescription.Text & "' where CustID='" & txtid.Text & "';"
        cmd.ExecuteNonQuery()
        MessageBox.Show("Update Succes")
        Close()
    End Sub

    Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
        Me.DialogResult = Windows.Forms.DialogResult.Cancel
    End Sub
End Class